package com.ui.basic.service.stduser;

import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ui.basic.command.CommandChangePswd;
import com.ui.basic.ibatis.dao.CommonDAO;
import com.ui.basic.ibatis.dao.system.TblSUserDAO;

@Service("changePasswordService")
public class ChangePasswordServiceImpl implements ChangePasswordService {
	private static final transient org.apache.commons.logging.Log LOGGER = org.apache.commons.logging.LogFactory
			.getLog(ChangePasswordServiceImpl.class);

	@Autowired
	private CommonDAO commonDAO;
	@Autowired
	private TblSUserDAO tblSUserDAO;
	
	public void setCommonDAO(CommonDAO commonDAO) {
		this.commonDAO = commonDAO;
	}

	public void setTblSUserDAO(TblSUserDAO tblSUserDAO) {
		this.tblSUserDAO = tblSUserDAO;
	}

	public void save(CommandChangePswd commandChangePswd) throws SQLException {
		LOGGER.debug(">>>ChangePasswordServiceImpl.save");
		tblSUserDAO.updateByPrimaryKeySelective(commandChangePswd.getUser());
	}

	public String convertMD5(String password) throws SQLException {
		LOGGER.debug(">>>ChangePasswordServiceImpl.convertMD5");
		
		return commonDAO.convertMD5(password);
	}
}
